package com.learn.hibernatevalidator.chapter08;

import jakarta.validation.*;
import jakarta.validation.constraintvalidation.SupportedValidationTarget;
import jakarta.validation.constraintvalidation.ValidationTarget;

import java.lang.annotation.*;

/**
 * @author: liyf
 * @create: 2025-01-19 15:24
 **/
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {ELAssert.Validator.class})
@Documented
public @interface ELAssert {

    String message() default "{org.hibernate.validator.referenceguide.chapter03.crossparameter.ELAssert.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    ConstraintTarget validationAppliesTo() default ConstraintTarget.IMPLICIT;

    String expression();

    @SupportedValidationTarget({
            ValidationTarget.PARAMETERS,
            ValidationTarget.ANNOTATED_ELEMENT
    })
    class Validator implements ConstraintValidator<ELAssert, Object[]> {

        @Override
        public boolean isValid(Object[] value, ConstraintValidatorContext context) {
            return false;
        }
    }
}
